<?php

class MysqlPdoDriver extends PdoDriver {
    
    /**
     * 初始化连接
     * @param    array $config    
     * @return   void
     */
    public function __construct($config) {
        list($host, $port) = explode(':', $config['host']); 
        $this->pdo = new PDO('mysql:dbname='.$config['database'].';host='.$host.';port='.$port,  $config['login'], $config['password']);
        $this->config = $config;
        $this->prefix = $config['prefix'];
        if (!empty($config['encoding'])) {
            $this->setCharset($config['encoding']);
        }
    }
    
    /**
     * 设置MySQL编码
     *
     * @param string $encoding
     */
    public function setCharset($encoding) {
        $this->pdo->exec("SET NAMES '$encoding'");
    }
    
    public function quoteIdentifierSymbol($str) {
        return '`'.$str.'`';
    }
}

